<template>
  <div class="book-list">
    <div class="book-item" v-for="item in booksList[keyType]" :key="item">
      <div class="top-img">
        <img :src="item.src" alt="" />
      </div>
      <div class="botom">
        <div class="title">{{ item.title }}</div>
        <div class="time">{{ item.time }}</div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref, toRefs } from "vue"
import HistoryIcon from "@/assets/images/books/history.jpg"
import BookIcon from "@/assets/images/books/book.jpg"
import PersonIcon from "@/assets/images/books/person.jpg"
import MoneyIcon from "@/assets/images/books/money.jpg"
import PsychologyIcon from "@/assets/images/books/psychology.jpg"
import Biographies from "@/assets/images/books/biographies.jpg"

const props = defineProps<{
  keyType: string
}>()
const { keyType } = toRefs(props)

const booksList = {
  literature: [
    {
      src: HistoryIcon,
      title: "文学作品1",
      time: "2021-04-26"
    },
    {
      src: BookIcon,
      title: "文学作品2",
      time: "2020-02-10"
    }
  ],
  history: [
    {
      src: PersonIcon,
      title: "文学作品3",
      time: "2020-03-25"
    },
    {
      src: MoneyIcon,
      title: "文学作品4",
      time: "2019-04-25"
    }
  ],
  development: [
    {
      src: PsychologyIcon,
      title: "文学作品5",
      time: "2018-05-28"
    }
  ],
  money: [
    {
      src: Biographies,
      title: "文学作品6",
      time: "2013-10-25"
    }
  ],
  psychology: [
    {
      src: Biographies,
      title: "文学作品7",
      time: "2008-11-25"
    },
    {
      src: Biographies,
      title: "文学作品8",
      time: "2021-05-25"
    },
    {
      src: Biographies,
      title: "文学作品9",
      time: "2023-01-25"
    }
  ],
  perpson: [
    {
      src: Biographies,
      title: "文学作品10",
      time: "2023-02-25"
    },
    {
      src: Biographies,
      title: "文学作品11",
      time: "2023-03-25"
    }
  ]
}
</script>

<style scoped lang="scss">
.book-list {
  width: 97.5%;
  height: auto;
  padding: 25px 12px;
  padding-top: 34px;
  display: flex;
  flex-wrap: wrap;

  .book-item {
    width: 90px;
    height: 170px;
    margin-right: 15px;
    margin-bottom: 13px;
    cursor: pointer;

    .top-img {
      width: 90px;
      height: 120px;

      img {
        width: 100%;
        height: 100%;
      }
    }

    .botom {
      padding: 5px 0;
      box-sizing: border-box;
      .title {
        font-size: 12px;
        color: #888;
      }

      .time {
        font-size: 11px;
        margin-top: 5px;
        color: #999;
      }
    }
  }
}
</style>
